package com.nidu.demo.user.convertor;

import com.nidu.demo.base.BaseConvertor;
import com.nidu.demo.convertor.MapStructConfig;
import com.nidu.demo.user.dto.UserCO;
import com.nidu.demo.user.dto.UserProfileCO;
import com.nidu.demo.user.mapper.dataobject.UserDO;
import com.nidu.demo.user.model.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(config = MapStructConfig.class)
public interface UserConvertor extends BaseConvertor<UserDO, User, UserCO> {
    
    @Override
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    @Mapping(target = "updateBy", ignore = true)
    UserDO toDataObject(User user);

    /**
     * User 转换为 UserProfileCO
     *
     * @param user OAuth2访问令牌
     * @return 个人中心信息
     */
    UserProfileCO toUserProfileCO(User user);
} 